home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00034_Character persistent parent script.ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  8.1 KB  |  265 lines

  1. property pDanceLoops, pCharCode, pName, pCharInfo, pImpatience, pLikesGender, pHasEverOrdered, pIntoxication, pDrinkTicket, pOver21, pBirthdate, pBirthDate2, pAlreadyCarded, pExpirationDate, pExpirationDate2, pCharmed, pBouncedPermanently, pNumVisits, pNumDrinks, pBuzzMin, pBlottoMin, pPassedOutMin, pTotalAlcohol, pFlashLabels, pFlashCharMember, pFlashMouthMember, pCharacterActions, pFavoriteSong, pHatedSong, pFirstAppearance, pVOpath
  2. global debug
  3.  
  4. on bounced me
  5.   global gImplementedCharacters
  6.   if pAlreadyCarded and not pOver21 then
  7.     pBouncedPermanently = 1
  8.   end if
  9. end
  10.  
  11. on mReinitialize me
  12.   global gImplementedCharacters
  13.   pCharacterActions = getCharActions(pCharCode)
  14.   pCharInfo = gImplementedCharacters[pCharCode]
  15.   pName = pCharInfo[#DISPLAY_NAME]
  16.   pImpatience = pCharInfo[#IMPATIENCE]
  17.   pFirstAppearance = pCharInfo[#MINLEVEL]
  18.   pFlashCharMember = flashMember(pCharCode)
  19.   pFlashMouthMember = flashMouthMember(pCharCode)
  20.   pVOpath = setVOPath(pCharCode)
  21. end
  22.  
  23. on new me, charCode
  24.   global gSongList, gForceUnderage
  25.   pFavoriteSong = random(count(gSongList))
  26.   pHatedSong = pFavoriteSong
  27.   repeat while pHatedSong = pFavoriteSong
  28.     pHatedSong = random(count(gSongList))
  29.   end repeat
  30.   pCharCode = charCode
  31.   mReinitialize(me)
  32.   pBouncedPermanently = 0
  33.   pLikesGender = randomFromWeightedList(pCharInfo[#SexPref], [#male, #female, #bi])
  34.   pAlreadyCarded = 0
  35.   pDrinkTicket = 0
  36.   pCharmed = 0
  37.   pNumVisits = 0
  38.   pNumDrinks = 0
  39.   pTotalAlcohol = 0
  40.   pBuzzMin = pCharInfo[#BUZZMIN]
  41.   pBlottoMin = pCharInfo[#BLOTTOMIN]
  42.   pPassedOutMin = pCharInfo[#POUTMIN]
  43.   pFlashLabels = VOID
  44.   pIntoxication = #sober
  45.   ageFactor = pCharInfo[#UF]
  46.   if (ageFactor = 0) or inRecipeMode() then
  47.     pOver21 = 1
  48.     ageInYears = pCharInfo[#UY]
  49.     if ageInYears = 0 then
  50.       ageInYears = 100
  51.     end if
  52.   else
  53.     if (random(ageFactor) > 1) and not gForceUnderage then
  54.       pOver21 = 1
  55.       ageInYears = random(5) + 20
  56.     else
  57.       pOver21 = 0
  58.       ageInYears = pCharInfo[#UY]
  59.       ageInYears = ageInYears + random(10) - 9
  60.     end if
  61.   end if
  62.   currentYear = systemDate().year
  63.   currentMonth = systemDate().month
  64.   currentDay = systemDate().day
  65.   pExpirationDate = randomDateInFuture()
  66.   pExpirationDate2 = randomDateInFuture()
  67.   if pOver21 then
  68.     year = currentYear - max(22, ageInYears + 1)
  69.     pBirthdate = date(year, random(12), random(31))
  70.     pBirthDate2 = date(year - random(2) + 1, random(12), random(31))
  71.   else
  72.     year = currentYear - 17 - random(3)
  73.     pBirthdate = date(year, random(12), random(31))
  74.     pBirthDate2 = date(year + random(2) - 1, random(12), random(31))
  75.   end if
  76.   if checkAge(systemDate(), pBirthdate, 21) <> pOver21 then
  77.     debugAlert("Error in date calculation" && pBirthdate)
  78.   end if
  79.   if checkAge(systemDate(), pBirthDate2, 21) <> pOver21 then
  80.     debugAlert("Error in date calculation" && pBirthDate2)
  81.   end if
  82.   return me
  83. end
  84.  
  85. on incrementDrinks me
  86.   pNumDrinks = pNumDrinks + 1
  87. end
  88.  
  89. on incrementAlcohol me, newBooze
  90.   pTotalAlcohol = pTotalAlcohol + newBooze
  91. end
  92.  
  93. on incrementNumVisits me
  94.   pNumVisits = pNumVisits + 1
  95. end
  96.  
  97. on approachAndGreet me
  98.   global gPearlyGates
  99.   if pNumVisits > 1 then
  100.     greet = #GREETB
  101.   else
  102.     greet = #GREETA
  103.   end if
  104.   if gPearlyGates and (pCharCode = #BC) then
  105.     playAnim(me, [#approach, #greetC], [#approaching, #greeting], [#arriveDone, #heavenGreetDone])
  106.   else
  107.     playAnim(me, [#approach, greet], [#approaching, #greeting], [#arriveDone, #greetDone])
  108.   end if
  109. end
  110.  
  111. on musicCheck me
  112.   global gCurrentSong, gSongList
  113.   if not busy(me) then
  114.     if pFavoriteSong = gCurrentSong then
  115.       pDanceLoops = 0
  116.       playAnim(me, #dance)
  117.     end if
  118.   end if
  119. end
  120.  
  121. on resetIntoxication me
  122.   getIntoxication(me)
  123.   if pIntoxication = #passedOut then
  124.     mSoberUp(me, 5)
  125.     getIntoxication(me)
  126.   end if
  127. end
  128.  
  129. on mSoberUp me, amountToSober
  130.   if voidp(amountToSober) then
  131.     amountToSober = currentLevel(#SOBERUP)
  132.   end if
  133.   pTotalAlcohol = max(0, pTotalAlcohol - amountToSober)
  134. end
  135.  
  136. on getIntoxication me
  137.   global gGameSetup, gGameLevel
  138.   if pTotalAlcohol > pPassedOutMin then
  139.     pIntoxication = #passedOut
  140.   else
  141.     if pTotalAlcohol > pBlottoMin then
  142.       pIntoxication = #blotto
  143.     else
  144.       if pTotalAlcohol > pBuzzMin then
  145.         pIntoxication = #buzzed
  146.       else
  147.         pIntoxication = #sober
  148.       end if
  149.     end if
  150.   end if
  151.   return pIntoxication
  152. end
  153.  
  154. on nextGlassMember me, glassPosition
  155.   global gBarTopManager
  156.   mySlot = SpriteToBarSlot(me.spriteNum)
  157.   glassType = getBarTopGlass(gBarTopManager, mySlot)
  158.   if glassType = #beer then
  159.     if pCharCode = #SM then
  160.       contents = barSlotToGlassSprite(gBarTopManager, mySlot).pContents
  161.       if contents[#limetwist] or contents[#lemontwist] then
  162.         return "SM_PEN_" & glassPosition
  163.       end if
  164.     end if
  165.   end if
  166.   return pCharCode & "_" & glassPrefix(glassType) & "_" & glassPosition
  167. end
  168.  
  169. on nextHandMember me, glassPosition
  170.   return pCharCode & "_" & "hand" & "_" & glassPosition
  171. end
  172.  
  173. on setFlashLabels me, flashSprite, testMe
  174.   if voidp(pFlashLabels) then
  175.     pFlashLabels = getFlashLabels(me, flashSprite, testMe)
  176.   end if
  177.   return pFlashLabels
  178. end
  179.  
  180. on getFlashLabels me, flashSprite, testMe
  181.   flashSprite = sprite(flashSprite)
  182.   memberNum = flashSprite.member
  183.   frameCount = memberNum.frameCount
  184.   labelList = []
  185.   repeat with X = 1 to frameCount
  186.     thisLabel = getFrameLabel(flashSprite, X)
  187.     if thisLabel <> EMPTY then
  188.       add(labelList, [#label: thisLabel, #start: X, #end: X, #mid: []])
  189.       previous = labelList[labelList.count]
  190.       repeat with Y = X + 1 to frameCount
  191.         thisLabel = getFrameLabel(flashSprite, Y)
  192.         if thisLabel <> EMPTY then
  193.           if thisLabel starts "End" then
  194.             previous[#end] = Y
  195.             exit repeat
  196.             next repeat
  197.           end if
  198.           add(previous[#mid], [#label: thisLabel, #start: Y])
  199.         end if
  200.       end repeat
  201.       X = Y
  202.     end if
  203.   end repeat
  204.   if debug then
  205.     testAgainst = ["APPROACH", "BECKON", "PCHARM", "NCHARM", "XNCHARM", "XPCHARM", "NDRINK", "DRINK", "PDRINK", "ANTIC1", "ANTIC2", "ANTIC3", "DANCE", "RETREAT", "BASE1", "BOUNCE", "SBUZZ", "SBLOTTO", "SMOVE", "POUT", "FLATTER", "TBASE", "TLEFT", "TRIGHT"]
  206.     put "Name:" && memberNum.fileName
  207.     put "Name:" && memberNum.name
  208.     put "Frames:" && frameCount
  209.     put "Character" && pCharCode
  210.     repeat with mine in labelList
  211.       put "This label" && mine
  212.       if getOne(testAgainst, mine[#label]) = 0 then
  213.         put mine[#label] && "not found in test list"
  214.       end if
  215.     end repeat
  216.     put count(labelList)
  217.     repeat with whatever in testAgainst
  218.       foundit = 0
  219.       repeat with mine in labelList
  220.         if mine[#label] = whatever then
  221.           foundit = 1
  222.           exit repeat
  223.         end if
  224.       end repeat
  225.       if not foundit then
  226.         put whatever && "not found in this character's file"
  227.       end if
  228.     end repeat
  229.   end if
  230.   return labelList
  231. end
  232.  
  233. on checkCharActions me
  234.   if (pCharacterActions = [:]) or voidp(pCharacterActions) then
  235.   else
  236.     repeat with X = 1 to count(pCharacterActions)
  237.       Current = string(getPropAt(pCharacterActions, X)) && pCharacterActions[X]
  238.       if voidp(pCharacterActions[X][1]) then
  239.         put "*********************** WARNING ***********************" && Current
  240.         put "Problem with" && Current && "for character" && pCharCode
  241.         next repeat
  242.       end if
  243.     end repeat
  244.     repeat with verify in [#ABLOTTO, #ABUZZ, #approach, #ASOBER, #base1, #tbase, #beckon, #bounce, #CARDEXCUSE, #CARDGEN, #CARDNEG, #dance, #drink, #DRINKD, #DRINKS, #DRINKDD, #flatter, #GREETA, #GREETB, #nCharm, #NDRINKD, #NDRINKS, #NDRINKZ, #passOut, #PCharm, #PDRINKD, #PDRINKS, #retreat, #TICKET, #WDRINKD, #WDRINKS, #WDRINKZ, #WORDERD, #WORDERS, #WORDERZ, #XNCHARM, #XPCHARM, #tLeft, #tRight]
  245.       found = 0
  246.       repeat with X = 1 to count(pCharacterActions)
  247.         if getPropAt(pCharacterActions, X) = verify then
  248.           found = 1
  249.           exit repeat
  250.         end if
  251.       end repeat
  252.       if not found then
  253.         next repeat
  254.       end if
  255.     end repeat
  256.     repeat with X = 1 to count(pCharacterActions)
  257.       if pCharacterActions[X][1] = [#anim: "BASE1"] then
  258.         prop = getPropAt(pCharacterActions, X)
  259.         if prop <> #base1 then
  260.         end if
  261.       end if
  262.     end repeat
  263.   end if
  264. end
  265.